diff options
author | Hubert Plociniczak <hubert.plociniczak@gmail.com> | 2012-06-25 09:55:31 +0200 |
---|---|---|
committer | Hubert Plociniczak <hubert.plociniczak@gmail.com> | 2012-06-25 15:08:41 +0200 |
commit | e7feeaafe6ba83171714ca78b06afabb9320d20d (patch) | |
tree | ea68b214475798ebed23e1874117285f81182f72 | |
parent | cfc0e18dc55b33274c1275c192ade4a8d707d635 (diff) | |
download | scala-e7feeaafe6ba83171714ca78b06afabb9320d20d.tar.gz scala-e7feeaafe6ba83171714ca78b06afabb9320d20d.tar.bz2 scala-e7feeaafe6ba83171714ca78b06afabb9320d20d.zip |
Minor followup on SI-4842: remove awkward condition. Review by @retronym.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 4 | ||||
-rw-r--r-- | test/files/neg/t4842.check | 7 | ||||
-rw-r--r-- | test/files/neg/t4842.scala (renamed from test/files/neg/t4842b.scala) | 4 | ||||
-rw-r--r-- | test/files/neg/t4842a.check | 4 | ||||
-rw-r--r-- | test/files/neg/t4842a.scala | 3 | ||||
-rw-r--r-- | test/files/neg/t4842b.check | 4 |
6 files changed, 13 insertions, 13 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 69d3fd7f47..6bb980260f 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1833,7 +1833,7 @@ trait Typers extends Modes with Adaptations with Tags { val params = fn.tpe.params val args2 = if (params.isEmpty || !isRepeatedParamType(params.last.tpe)) args else args.take(params.length - 1) :+ EmptyTree - assert(sameLength(args2, params), "mismatch " + clazz + " " + (params map (_.tpe)) + " " + args2)//debug + assert(sameLength(args2, params) || call.isErrorTyped, "mismatch " + clazz + " " + (params map (_.tpe)) + " " + args2)//debug (superConstr, args1 ::: args2) case Block(stats, expr) if !stats.isEmpty => decompose(stats.last) @@ -2036,7 +2036,7 @@ trait Typers extends Modes with Adaptations with Tags { transformedOrTyped(ddef.rhs, EXPRmode, tpt1.tpe) } - if (meth.isClassConstructor && !isPastTyper && !reporter.hasErrors && !meth.owner.isSubClass(AnyValClass)) { + if (meth.isClassConstructor && !isPastTyper && !meth.owner.isSubClass(AnyValClass)) { // At this point in AnyVal there is no supercall, which will blow up // in computeParamAliases; there's nothing to be computed for Anyval anyway. if (meth.isPrimaryConstructor) diff --git a/test/files/neg/t4842.check b/test/files/neg/t4842.check new file mode 100644 index 0000000000..b53bbdbd15 --- /dev/null +++ b/test/files/neg/t4842.check @@ -0,0 +1,7 @@ +t4842.scala:2: error: self constructor arguments cannot reference unconstructed `this` + def this(x: Int) = this(new { println(Foo.this)}) // error + ^ +t4842.scala:6: error: self constructor arguments cannot reference unconstructed `this` + def this() = { this(???)(new { println(TypeArg.this.x) } ); println("next") } // error + ^ +two errors found diff --git a/test/files/neg/t4842b.scala b/test/files/neg/t4842.scala index a7996cc061..c6244efda7 100644 --- a/test/files/neg/t4842b.scala +++ b/test/files/neg/t4842.scala @@ -1,3 +1,7 @@ +class Foo (x: AnyRef) { + def this(x: Int) = this(new { println(Foo.this)}) // error +} + class TypeArg[X](val x: X)(a: AnyRef) { def this() = { this(???)(new { println(TypeArg.this.x) } ); println("next") } // error } diff --git a/test/files/neg/t4842a.check b/test/files/neg/t4842a.check deleted file mode 100644 index 39d77bfc48..0000000000 --- a/test/files/neg/t4842a.check +++ /dev/null @@ -1,4 +0,0 @@ -t4842a.scala:2: error: self constructor arguments cannot reference unconstructed `this` - def this(x: Int) = this(new { println(Foo.this)}) // error - ^ -one error found diff --git a/test/files/neg/t4842a.scala b/test/files/neg/t4842a.scala deleted file mode 100644 index 78360effb4..0000000000 --- a/test/files/neg/t4842a.scala +++ /dev/null @@ -1,3 +0,0 @@ -class Foo (x: AnyRef) { - def this(x: Int) = this(new { println(Foo.this)}) // error -} diff --git a/test/files/neg/t4842b.check b/test/files/neg/t4842b.check deleted file mode 100644 index c7ccd5e059..0000000000 --- a/test/files/neg/t4842b.check +++ /dev/null @@ -1,4 +0,0 @@ -t4842b.scala:2: error: self constructor arguments cannot reference unconstructed `this` - def this() = { this(???)(new { println(TypeArg.this.x) } ); println("next") } // error - ^ -one error found |