File tree Expand file tree Collapse file tree 4 files changed +48
-22
lines changed Expand file tree Collapse file tree 4 files changed +48
-22
lines changed Original file line number Diff line number Diff line change @@ -661,7 +661,7 @@ class ClassfileParser(
661
661
for (entry <- innerClasses.values) {
662
662
// create a new class member for immediate inner classes
663
663
if (entry.outerName == currentClassName) {
664
- val file = ctx.platform.classPath.findSourceFile (entry.externalName.toString) getOrElse {
664
+ val file = ctx.platform.classPath.findBinaryFile (entry.externalName.toString) getOrElse {
665
665
throw new AssertionError (entry.externalName)
666
666
}
667
667
enterClassAndModule(entry, file, entry.jflags)
Original file line number Diff line number Diff line change @@ -848,26 +848,21 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {
848
848
849
849
val nextBinder = afterTest.asTerm
850
850
851
- def needsOuterTest ( patType : Type , selType : Type , currentOwner : Symbol ): Boolean = {
851
+ def outerTestNeeded ( implicit ctx : Context ): Boolean = {
852
852
// See the test for SI-7214 for motivation for dealias. Later `treeCondStrategy#outerTest`
853
853
// generates an outer test based on `patType.prefix` with automatically dealises.
854
- patType.dealias match {
855
- case tref @ TypeRef (pre, name) =>
856
- (pre ne NoPrefix ) && tref.symbol.isClass &&
857
- ExplicitOuter .needsOuterIfReferenced(tref.symbol.asClass)
854
+ expectedTp.dealias match {
855
+ case tref @ TypeRef (pre : SingletonType , name) =>
856
+ val s = tref
857
+ s.symbol.isClass &&
858
+ ExplicitOuter .needsOuterIfReferenced(s.symbol.asClass)
858
859
case _ =>
859
860
false
860
861
}
861
862
}
862
863
863
864
override lazy val introducedRebindings = NoRebindings
864
865
865
- def outerTestNeeded = {
866
- val np = expectedTp.normalizedPrefix
867
- val ts = np.termSymbol
868
- (ts ne NoSymbol ) && needsOuterTest(expectedTp, testedBinder.info, ctx.owner)
869
- }
870
-
871
866
// the logic to generate the run-time test that follows from the fact that
872
867
// a `prevBinder` is expected to have type `expectedTp`
873
868
// the actual tree-generation logic is factored out, since the analyses generate Cond(ition)s rather than Trees
Original file line number Diff line number Diff line change @@ -240,22 +240,16 @@ abstract class ClassPath {
240
240
def findClass (name : String ): Option [AnyClassRep ] =
241
241
name.splitWhere(_ == '.' , doDropIndex = true ) match {
242
242
case Some ((pkg, rest)) =>
243
- val rep = packages find (_.name == pkg) flatMap (_ findClass rest)
244
- rep map {
245
- case x : ClassRep => x
246
- case x => throw new FatalError (" Unexpected ClassRep '%s' found searching for name '%s'" .format(x, name))
247
- }
243
+ packages find (_.name == pkg) flatMap (_ findClass rest)
248
244
case _ =>
249
245
classes find (_.name == name)
250
246
}
251
247
252
- def findSourceFile (name : String ): Option [AbstractFile ] =
253
- findClass(name) match {
254
- case Some (ClassRep (Some (x : AbstractFile ), _)) => Some (x)
255
- case _ => None
256
- }
248
+ def findBinaryFile (name : String ): Option [AbstractFile ] =
249
+ findClass(name).flatMap(_.binary)
257
250
258
251
def sortString = join(split(asClasspathString).sorted: _* )
252
+
259
253
override def equals (that : Any ) = that match {
260
254
case x : ClassPath => this .sortString == x.sortString
261
255
case _ => false
Original file line number Diff line number Diff line change
1
+ class Outer {
2
+
3
+ case class Inner ()
4
+
5
+ val inner : Inner = new Inner
6
+
7
+ def checkInstance (o : Outer ) =
8
+ o.inner.isInstanceOf [this .Inner ]
9
+
10
+ def checkPattern1 (i : Any ) =
11
+ i match {
12
+ case _ : Inner => true
13
+ case _ => false
14
+ }
15
+
16
+ def checkPattern2 (i : Any ) =
17
+ i match {
18
+ case Inner () => true
19
+ case _ => false
20
+ }
21
+
22
+ def checkEquals (o : Outer ) =
23
+ o.inner == inner
24
+ }
25
+
26
+ object Test {
27
+
28
+ def main (args : Array [String ]) = {
29
+ val o1 = new Outer
30
+ val o2 = new Outer
31
+ assert(o1.checkInstance(o2)) // ok
32
+ assert(! o1.checkPattern1(o2.inner)) // ok under scalac, fails for dotc-compiled code
33
+ assert(! o1.checkPattern2(o2.inner)) // ok under scalac, fails for dotc-compiled code
34
+ assert(! o1.checkEquals(o2)) // ok under scalac, fails for dotc-compiled code
35
+ }
36
+ }
37
+
You can’t perform that action at this time.
0 commit comments