AutoCompletion of code fail or crash often on fire

I create a Cocoa/ios project. Add the swift files on https://github.com/mamaral/Neon/tree/master/Source. Then try to recreate the sample:

let isLandscape : Bool = UIDevice.currentDevice().orientation.isLandscape.boolValue
let bannerHeight : CGFloat = view.height() * 0.43
let avatarHeightMultipler : CGFloat = isLandscape ? 0.75 : 0.43
let avatarSize = bannerHeight * avatarHeightMultipler

searchBar.fillSuperview()
bannerImageView.anchorAndFillEdge(.Top, xPad: 0, yPad: 0, otherSize: bannerHeight)
bannerMaskView.fillSuperview()
avatarImageView.anchorInCorner(.BottomLeft, xPad: 15, yPad: 15, width: avatarSize, height: avatarSize)
nameLabel.alignAndFillWidth(align: .ToTheRightCentered, relativeTo: avatarImageView, padding: 15, height: 120)
cameraButton.anchorInCorner(.BottomRight, xPad: 10, yPad: 7, width: 28, height: 28)
buttonContainerView.alignAndFillWidth(align: .UnderCentered, relativeTo: bannerImageView, padding: 0, height: 62)
buttonContainerView.groupAndFill(group: .Horizontal, views: [postButton, updateInfoButton, activityLogButton, moreButton], padding: 10)
buttonContainerView2.alignAndFillWidth(align: .UnderCentered, relativeTo: buttonContainerView, padding: 0, height: 128)
buttonContainerView2.groupAndFill(group: .Horizontal, views: [aboutView, photosView, friendsView], padding: 10)

I get several errors:

E: No member "isLandscape" on type "UIDeviceOrientation" [/Users/mamcx/Projects/FireApp/App/AppDelegate.swift (17)]
E: No static member "height" on type "View" [/Users/mamcx/Projects/FireApp/App/AppDelegate.swift (18)]

Now I try to autocomplete on:

UIDevice.

and get:

Internal error:

System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an object
  at RemObjects.Oxygene.Code.BinaryExpressionTransform.Phase1 (RemObjects.Oxygene.Code.Compiler.ScopeInfo aScope, RemObjects.Oxygene.Code.BinaryExpression binaryExpression, RemObjects.Oxygene.Code.Expression lLeft, RemObjects.Oxygene.Code.Expression lRight) [0x006ad] in <371357288d1c49ec8b632f7684c1f967>:0 
  at RemObjects.Oxygene.Code.BinaryExpressionTransform.ResolveExpression (RemObjects.Oxygene.Code.Compiler.ScopeInfo aScope, RemObjects.Oxygene.Code.BinaryExpression binaryExpression) [0x000dd] in <371357288d1c49ec8b632f7684c1f967>:0 
  at RemObjects.Oxygene.Code.Compiler.NewResolveExpressionAndStatement.VisitExpression (RemObjects.Oxygene.Code.Compiler.ScopeInfo aScope, RemObjects.Oxygene.Code.Expression element) [0x0068d] in <371357288d1c49ec8b632f7684c1f967>:0 
  at RemObjects.Oxygene.Code.BinaryExpressionTransform.ResolveExpression (RemObjects.Oxygene.Code.Compiler.ScopeInfo aScope, RemObjects.Oxygene.Code.BinaryExpression binaryExpression) [0x000ab] in <371357288d1c49ec8b632f7684c1f967>:0 
  at RemObjects.Oxygene.Code.Compiler.NewResolveExpressionAndStatement.VisitExpression (RemObjects.Oxygene.Code.Compiler.ScopeInfo aScope, RemObjects.Oxygene.Code.Expression element) [0x0068d] in <371357288d1c49ec8b632f7684c1f967>:0 
  at RemObjects.Oxygene.Code.BinaryExpressionTransform.ResolveExpression (RemObjects.Oxygene.Code.Compiler.ScopeInfo aScope, RemObjects.Oxygene.Code.BinaryExpression binaryExpression) [0x000ab] in <371357288d1c49ec8b632f7684c1f967>:0 
  at RemObjects.Oxygene.Code.Compiler.NewResolveExpressionAndStatement.VisitExpression (RemObjects.Oxygene.Code.Compiler.ScopeInfo aScope, RemObjects.Oxygene.Code.Expression element) [0x0068d] in <371357288d1c49ec8b632f7684c1f967>:0 
  at RemObjects.Oxygene.Code.UnaryExpressionTransform.ResolveExpression (RemObjects.Oxygene.Code.Compiler.ScopeInfo aScope, RemObjects.Oxygene.Code.UnaryExpression unaryExpression) [0x0003f] in <371357288d1c49ec8b632f7684c1f967>:0 
  at RemObjects.Oxygene.Code.Compiler.NewResolveExpressionAndStatement.VisitExpression (RemObjects.Oxygene.Code.Compiler.ScopeInfo aScope, RemObjects.Oxygene.Code.Expression element) [0x00678] in <371357288d1c49ec8b632f7684c1f967>:0 
  at RemObjects.Oxygene.Code.Compiler.Compiler.CheckDefined (RemObjects.Oxygene.Code.Compiler.ITypeResolutionScope aScope, RemObjects.Oxygene.Code.Expression aVal, System.Collections.Generic.HashSet`1[T] aExtra, System.Collections.Immutable.ImmutableSortedSet`1[System.String]& aPlat) [0x00154] in <371357288d1c49ec8b632f7684c1f967>:0 
  at RemObjects.Oxygene.Code.ElementsSyntaxModel.IntCreateTypeFor (RemObjects.Oxygene.Code.Compiler.Compiler fCompiler, System.String aOriginalName, RemObjects.Oxygene.Analysis.SLinkedListNode`1[T] aItems, RemObjects.Oxygene.Code.IParsedType aNestedIn) [0x000a5] in <371357288d1c49ec8b632f7684c1f967>:0 
  at RemObjects.Oxygene.Code.ElementsSyntaxModel.CreateTypeFor (System.String aOriginalName, RemObjects.Oxygene.Analysis.SLinkedListNode`1[T] aItems) [0x0003c] in <371357288d1c49ec8b632f7684c1f967>:0 
  at RemObjects.Oxygene.Code.ElementsSyntaxModel.IntFillTypes () [0x00c84] in <371357288d1c49ec8b632f7684c1f967>:0 
  at RemObjects.Oxygene.Code.ElementsSyntaxModel+<>c__DisplayClass1.<FillTypes>b__0 (System.Threading.Tasks.Task a) [0x00000] in <371357288d1c49ec8b632f7684c1f967>:0 
  at System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke () [0x00027] in <dbb16e0bacdc4a0f87478e401bc29b6c>:0 
  at System.Threading.Tasks.Task.Execute () [0x00016] in <dbb16e0bacdc4a0f87478e401bc29b6c>:0 
   --- End of inner exception stack trace ---
  at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00014] in <dbb16e0bacdc4a0f87478e401bc29b6c>:0 
  at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00052] in <dbb16e0bacdc4a0f87478e401bc29b6c>:0 
  at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout) [0x00000] in <dbb16e0bacdc4a0f87478e401bc29b6c>:0 
  at RemObjects.Oxygene.Code.Compiler.CodeCompletionCompiler.WaitForQueue () [0x00006] in <56bee51867284ae1a91d512670b2306b>:0 
  at RemObjects.Oxygene.Code.Compiler.CodeCompletionCompiler.TranslateOffsetWait (System.String aFileName, System.Int32 aRow, System.Int32 aCol) [0x00067] in <56bee51867284ae1a91d512670b2306b>:0 
  at (wrapper native-to-managed) RemObjects.Oxygene.Code.Compiler.CodeCompletionCompiler:TranslateOffsetWait (RemObjects.Oxygene.Code.Compiler.CodeCompletionCompiler,string,int,int,System.Exception&)
---> (Inner Exception #0) System.NullReferenceException: Object reference not set to an instance of an object
  at RemObjects.Oxygene.Code.BinaryExpressionTransform.Phase1 (RemObjects.Oxygene.Code.Compiler.ScopeInfo aScope, RemObjects.Oxygene.Code.BinaryExpression binaryExpression, RemObjects.Oxygene.Code.Expression lLeft, RemObjects.Oxygene.Code.Expression lRight) [0x006ad] in <371357288d1c49ec8b632f7684c1f967>:0 
  at RemObjects.Oxygene.Code.BinaryExpressionTransform.ResolveExpression (RemObjects.Oxygene.Code.Compiler.ScopeInfo aScope, RemObjects.Oxygene.Code.BinaryExpression binaryExpression) [0x000dd] in <371357288d1c49ec8b632f7684c1f967>:0 
  at RemObjects.Oxygene.Code.Compiler.NewResolveExpressionAndStatement.VisitExpression (RemObjects.Oxygene.Code.Compiler.ScopeInfo aScope, RemObjects.Oxygene.Code.Expression element) [0x0068d] in <371357288d1c49ec8b632f7684c1f967>:0 
  at RemObjects.Oxygene.Code.BinaryExpressionTransform.ResolveExpression (RemObjects.Oxygene.Code.Compiler.ScopeInfo aScope, RemObjects.Oxygene.Code.BinaryExpression binaryExpression) [0x000ab] in <371357288d1c49ec8b632f7684c1f967>:0 
  at RemObjects.Oxygene.Code.Compiler.NewResolveExpressionAndStatement.VisitExpression (RemObjects.Oxygene.Code.Compiler.ScopeInfo aScope, RemObjects.Oxygene.Code.Expression element) [0x0068d] in <371357288d1c49ec8b632f7684c1f967>:0 
  at RemObjects.Oxygene.Code.BinaryExpressionTransform.ResolveExpression (RemObjects.Oxygene.Code.Compiler.ScopeInfo aScope, RemObjects.Oxygene.Code.BinaryExpression binaryExpression) [0x000ab] in <371357288d1c49ec8b632f7684c1f967>:0 
  at RemObjects.Oxygene.Code.Compiler.NewResolveExpressionAndStatement.VisitExpression (RemObjects.Oxygene.Code.Compiler.ScopeInfo aScope, RemObjects.Oxygene.Code.Expression element) [0x0068d] in <371357288d1c49ec8b632f7684c1f967>:0 
  at RemObjects.Oxygene.Code.UnaryExpressionTransform.ResolveExpression (RemObjects.Oxygene.Code.Compiler.ScopeInfo aScope, RemObjects.Oxygene.Code.UnaryExpression unaryExpression) [0x0003f] in <371357288d1c49ec8b632f7684c1f967>:0 
  at RemObjects.Oxygene.Code.Compiler.NewResolveExpressionAndStatement.VisitExpression (RemObjects.Oxygene.Code.Compiler.ScopeInfo aScope, RemObjects.Oxygene.Code.Expression element) [0x00678] in <371357288d1c49ec8b632f7684c1f967>:0 
  at RemObjects.Oxygene.Code.Compiler.Compiler.CheckDefined (RemObjects.Oxygene.Code.Compiler.ITypeResolutionScope aScope, RemObjects.Oxygene.Code.Expression aVal, System.Collections.Generic.HashSet`1[T] aExtra, System.Collections.Immutable.ImmutableSortedSet`1[System.String]& aPlat) [0x00154] in <371357288d1c49ec8b632f7684c1f967>:0 
  at RemObjects.Oxygene.Code.ElementsSyntaxModel.IntCreateTypeFor (RemObjects.Oxygene.Code.Compiler.Compiler fCompiler, System.String aOriginalName, RemObjects.Oxygene.Analysis.SLinkedListNode`1[T] aItems, RemObjects.Oxygene.Code.IParsedType aNestedIn) [0x000a5] in <371357288d1c49ec8b632f7684c1f967>:0 
  at RemObjects.Oxygene.Code.ElementsSyntaxModel.CreateTypeFor (System.String aOriginalName, RemObjects.Oxygene.Analysis.SLinkedListNode`1[T] aItems) [0x0003c] in <371357288d1c49ec8b632f7684c1f967>:0 
  at RemObjects.Oxygene.Code.ElementsSyntaxModel.IntFillTypes () [0x00c84] in <371357288d1c49ec8b632f7684c1f967>:0 
  at RemObjects.Oxygene.Code.ElementsSyntaxModel+<>c__DisplayClass1.<FillTypes>b__0 (System.Threading.Tasks.Task a) [0x00000] in <371357288d1c49ec8b632f7684c1f967>:0 
  at System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke () [0x00027] in <dbb16e0bacdc4a0f87478e401bc29b6c>:0 
  at System.Threading.Tasks.Task.Execute () [0x00016] in <dbb16e0bacdc4a0f87478e401bc29b6c>:0 <---

Now, I restart the IDE and it not generate a crash but the autocomplete list is limited to “as do extension…”.

Note: I have build 10.0.0.2264

Can you send me the exact project as it is now?

Sure, is here:
FireApp.zip (123.9 KB)

hmm, looks fine here :frowning:

error wise I get, somewhat expectedly:

let isLandscape : Bool = UIDevice.currentDevice()..orientation.isLandscape.boolValue // E480 Cannot use the binary operator ".."
																							 // E46 Unknown identifier "orientation"
let bannerHeight : CGFloat = View.height() * 0.43 // E43 No static member "height" on type "View"

Ah, i can reproduce that CC fails between the two dots

		let isLandscape : Bool = UIDevice.currentDevice.|.orientation.isLandscape.boolValue

fails, but this:

		let isLandscape : Bool = UIDevice.currentDevice.|

shows the right CC just fine. logged as 79794: CC broken between two dots.

the second error is expected, (a) there;'s no height on View, you’d want frame.size.height. but more importantly, there’s no View instance here, so it access the View class, which has neither height nor frame as static properties. window?.frame.size.height works.

UIDeviceOrientation also has no isLandcape afaict, it’s defined as

public enum UIKit.UIDeviceOrientation { 
    case UIDeviceOrientationUnknown = 0
    case Unknown = 0
    case UIDeviceOrientationPortrait = 1
    case Portrait = 1
    case UIDeviceOrientationPortraitUpsideDown = 2
    case PortraitUpsideDown = 2
    case UIDeviceOrientationLandscapeLeft = 3
    case LandscapeLeft = 3
    case UIDeviceOrientationLandscapeRight = 4
    case LandscapeRight = 4
    case UIDeviceOrientationFaceUp = 5
    case FaceUp = 5
    case UIDeviceOrientationFaceDown = 6
    case FaceDown = 6
}

buit this would work:

UIDevice.currentDevice.orientation == .LandscapeLeft || UIDevice.currentDevice.orientation == .LandscapeRight

Yeah, I know the code is not right. Is clear that I can share swift code blindy between fire/xcode as I expected, but I think autocompletion must be resilent agains this kind of stuff…

What kind of flavor is fire using for Coccoa APIs? I do the same on XCode with Swift 3.2/ iOS 11.2, and the corrected code is:

    let isLandscape : Bool = UIDevice.current.orientation.isLandscape
    let bannerHeight : CGFloat = 200.0 * 0.43
    let avatarHeightMultipler : CGFloat = isLandscape ? 0.75 : 0.43
    let avatarSize = bannerHeight * avatarHeightMultipler

However, the same code on fire not work. It break on UIDevice.current

the flavor that is in the Objective-C header files that ship with the frameworks.

UIDevice.currentDevice is the actual name of that property. It seems that that should get renamed to current using Apple’s messed up “Grand Rename” obfuscation (see https://docs.elementscompiler.com/Silver/GrandRename/), which I personally think is terrible and destroys the beautifully crafted Cocoa APIs.

Essentially, every Cocoa API has to names — one real name of the class/member in Objective-C and one mangled one that Apple Swift sees. For Silver, we support those renames and both versions should be available, the good and the ugly.

So Silver should see the current too, I’ll need to investigate why it doesn’t…

I know why it doesn’t. because Apples own rules for how to trim say it should not, because trimming the type name suffix is dependent on the remaining words to be of a certain type (verbs or prepositions), which “current” is not :(. It’s lovely how Apple’s Renameing doesn’t follow its own defined rules…

IIRC we had a similar case for “standard” a while back and I had to add a hack for that. I’ll add “current” to the hack list as well, so the next time we import new SDKs UIDevice.current, undescriptive as it is, will work.

I find another issue:

public class func drawCanvas1(frame targetFrame: CGRect = CGRect(x: 0, y: 0, width: 240, height: 120), resizing: ResizingBehavior = .aspectFit) {
	//// General Declarations
	let context = UIGraphicsGetCurrentContext()!
	
	//// Resize to Target Frame
	context.saveGState()
	let resizedFrame: CGRect = resizing.apply(rect: CGRect(x: 0, y: 0, width: 240, height: 120), target: targetFrame)
	context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
	context.scaleBy(x: resizedFrame.width / 240, y: resizedFrame.height / 120)
	
	context.restoreGState()

}

It claim on context.saveGState() “No such member”. If I try to auto-complete it it crash

App.bugreport.txt (12.1 KB)

sorry for the delay, busy day. i’ll try and repro tomorrow.

I’m sure we’ll need the testcase for this. but I’ll log for the CC team…

Thanks, logged as bugs://79872

to be clear, this doesn’t actually crash, despite what the subject said, right? it shows shows an error when you invoke CC?

It crash the autocompletion and IDE help to inspect the code. but the IDE stay alive. After this the only option is restart the IDE to try again.

I’m sorry, but I don’t understand. Either it crashes, or it stays alive, it can’t do both? If CC just shows that error, but the IDE stays up, that’s not a crash?

Ok, then looking that way it not crash :slight_smile: However I say this because after that the autocompletion stop working for all the code.

Hello,

I tried to reproduce the issue with FireApp attached project. I tried invoke CC on different identifiers, including UIDevice., and I tried to type some code. Could you please check if the issue still reproduces for you? It doesn’t show here any more.

Thanks in advance.

bugs://79872 got closed with status cannotrepro.