From 5f50e0368e635db8279797095dbd34470722d5c7 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sat, 8 Nov 2014 22:50:47 +1000 Subject: SI-8534 Avoid crash in erroneous SelectFromTypeTree PR #2374 changed the behaviour of `typedSingletonTypeTree` in the presence of an error typed reference tree. It incorrectly returns the reference tree in case on an error. However, this is a term tree, which is an inconsistent result with the input type tree. Consequently, a `typedSelectInternal` later fails when using this as the qualifier of a `SelectFromTypeTree`. Both test cases enclosed show this symptom. This commit: - Returns `tree` rather than `refTyped` when `refTyped` is error typed or when it isn't suitable as a stable prefix. - Avoids issuing a cascading "not a stable prefix" error if the `refTyped` is error typed. - Adds an extra layer of defense in `typedSelectFromTypeTree` to bail out quickly if the qualifier is error typed. The last measure is not necessary to fix this bug. --- test/files/neg/t8534.check | 4 ++++ test/files/neg/t8534.scala | 7 +++++++ test/files/neg/t8534b.check | 4 ++++ test/files/neg/t8534b.scala | 4 ++++ test/files/neg/t963.check | 8 ++++---- 5 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 test/files/neg/t8534.check create mode 100644 test/files/neg/t8534.scala create mode 100644 test/files/neg/t8534b.check create mode 100644 test/files/neg/t8534b.scala (limited to 'test/files') diff --git a/test/files/neg/t8534.check b/test/files/neg/t8534.check new file mode 100644 index 0000000000..297e7c1beb --- /dev/null +++ b/test/files/neg/t8534.check @@ -0,0 +1,4 @@ +t8534.scala:6: error: MyTrait is not an enclosing class + class BugTest {def isTheBugHere(in: MyTrait.this.type#SomeData) = false} + ^ +one error found diff --git a/test/files/neg/t8534.scala b/test/files/neg/t8534.scala new file mode 100644 index 0000000000..f118d22b82 --- /dev/null +++ b/test/files/neg/t8534.scala @@ -0,0 +1,7 @@ +object line1 { + trait MyTrait +} +object line2 { + import line2._ + class BugTest {def isTheBugHere(in: MyTrait.this.type#SomeData) = false} +} diff --git a/test/files/neg/t8534b.check b/test/files/neg/t8534b.check new file mode 100644 index 0000000000..39ffa41194 --- /dev/null +++ b/test/files/neg/t8534b.check @@ -0,0 +1,4 @@ +t8534b.scala:3: error: stable identifier required, but foo.type found. + type T = foo.type#Foo + ^ +one error found diff --git a/test/files/neg/t8534b.scala b/test/files/neg/t8534b.scala new file mode 100644 index 0000000000..73b6703a9c --- /dev/null +++ b/test/files/neg/t8534b.scala @@ -0,0 +1,4 @@ +object Test { + def foo = "" + type T = foo.type#Foo +} diff --git a/test/files/neg/t963.check b/test/files/neg/t963.check index 4dc202c7bd..483e53c77d 100644 --- a/test/files/neg/t963.check +++ b/test/files/neg/t963.check @@ -1,9 +1,9 @@ -t963.scala:14: error: stable identifier required, but Test.this.y3.x found. +t963.scala:14: error: stable identifier required, but y3.x.type found. val w3 : y3.x.type = y3.x - ^ -t963.scala:17: error: stable identifier required, but Test.this.y4.x found. + ^ +t963.scala:17: error: stable identifier required, but y4.x.type found. val w4 : y4.x.type = y4.x - ^ + ^ t963.scala:10: error: type mismatch; found : AnyRef{def x: Integer} required: AnyRef{val x: Integer} -- cgit v1.2.3