Prechádzať zdrojové kódy

New Self doesn't always mean we are creating an instance of this type. Fixes #313

woollybah 7 rokov pred
rodič
commit
a0cc28703a
1 zmenil súbory, kde vykonal 7 pridanie a 1 odobranie
  1. 7 1
      expr.bmx

+ 7 - 1
expr.bmx

@@ -814,6 +814,8 @@ Type TNewObjectExpr Extends TExpr
 		Local it:TIdentType = TIdentType(ty)
 		Local iArgs:TExpr[] = SemantArgs(CopyArgs(args))
 
+		Local isNewSelf:Int = (it.ident = "self")
+		
 		ty=ty.Semant(True)
 		If Not ty Then
 			' maybe it's an instance of a type ?
@@ -877,7 +879,11 @@ Type TNewObjectExpr Extends TExpr
 			End If
 		EndIf
 
-		classDecl.attrs:|CLASS_INSTANCED
+		' New Self doesn't necessarily create an instance of ourself - we might be an instance of
+		' a subclass at the time...
+		If Not isNewSelf Then
+			classDecl.attrs:|CLASS_INSTANCED
+		End If
 
 		If TClassType(ty) Then
 			exprType=New TObjectType.Create(TClassType(ty).classDecl)