@@ -657,10 +657,14 @@ final class Analyzer(config: CommonPhaseConfig, initial: Boolean,
657
657
}
658
658
659
659
private def createNonExistentPublicMethod (methodName : MethodName ): MethodInfo = {
660
- val syntheticData = makeSyntheticMethodInfo(methodName, MemberNamespace .Public )
661
- val m = new MethodInfo (this , syntheticData, nonExistent = true )
662
- publicMethodInfos += methodName -> m
663
- m
660
+ /* Use getOrElseUpdate to avoid overriding an abstract method:
661
+ * When being called from lookupMethod, it is possible that an abstract
662
+ * method exists.
663
+ */
664
+ publicMethodInfos.getOrElseUpdate(methodName, {
665
+ val syntheticData = makeSyntheticMethodInfo(methodName, MemberNamespace .Public )
666
+ new MethodInfo (this , syntheticData, nonExistent = true )
667
+ })
664
668
}
665
669
666
670
def tryLookupMethod (methodName : MethodName ): Option [MethodInfo ] = {
@@ -959,6 +963,7 @@ final class Analyzer(config: CommonPhaseConfig, initial: Boolean,
959
963
960
964
def tryLookupStaticLikeMethod (namespace : MemberNamespace ,
961
965
methodName : MethodName ): Option [MethodInfo ] = {
966
+ assert(namespace != MemberNamespace .Public )
962
967
methodInfos(namespace).get(methodName)
963
968
}
964
969
@@ -1246,10 +1251,7 @@ final class Analyzer(config: CommonPhaseConfig, initial: Boolean,
1246
1251
s " $owner. ${methodName.simpleName.nameString}"
1247
1252
1248
1253
def reachStatic ()(implicit from : From ): Unit = {
1249
- assert(! isAbstract,
1250
- s " Trying to reach statically the abstract method $this" )
1251
-
1252
- checkExistent()
1254
+ checkConcrete()
1253
1255
1254
1256
calledFrom ::= from
1255
1257
if (! isReachable) {
@@ -1272,14 +1274,12 @@ final class Analyzer(config: CommonPhaseConfig, initial: Boolean,
1272
1274
def reach (inClass : ClassInfo )(implicit from : From ): Unit = {
1273
1275
assert(! namespace.isStatic,
1274
1276
s " Trying to dynamically reach the static method $this" )
1275
- assert(! isAbstract,
1276
- s " Trying to dynamically reach the abstract method $this" )
1277
1277
assert(owner.isAnyClass,
1278
1278
s " Trying to dynamically reach the non-class method $this" )
1279
1279
assert(! namespace.isConstructor,
1280
1280
s " Trying to dynamically reach the constructor $this" )
1281
1281
1282
- checkExistent ()
1282
+ checkConcrete ()
1283
1283
1284
1284
calledFrom ::= from
1285
1285
instantiatedSubclasses ::= inClass
@@ -1296,6 +1296,11 @@ final class Analyzer(config: CommonPhaseConfig, initial: Boolean,
1296
1296
_errors += MissingMethod (this , from)
1297
1297
}
1298
1298
1299
+ private def checkConcrete ()(implicit from : From ) = {
1300
+ if (nonExistent || isAbstract)
1301
+ _errors += MissingMethod (this , from)
1302
+ }
1303
+
1299
1304
private [this ] def doReach (): Unit = {
1300
1305
followReachabilityInfo(data.reachabilityInfo, owner.staticDependencies,
1301
1306
owner.externalDependencies, owner.dynamicDependencies)(FromMethod (this ))
0 commit comments