diff --git a/src/dotty/tools/dotc/core/Flags.scala b/src/dotty/tools/dotc/core/Flags.scala index b9e90173515e..68125f73eedd 100644 --- a/src/dotty/tools/dotc/core/Flags.scala +++ b/src/dotty/tools/dotc/core/Flags.scala @@ -342,6 +342,9 @@ object Flags { /** Symbol is a Java-style varargs method */ final val JavaVarargs = termFlag(38, "") + /** Symbol is a Java default method */ + final val DefaultMethod = termFlag(39, "") + // Flags following this one are not pickled /** Denotation is in train of being loaded and completed, used to catch cyclic dependencies */ diff --git a/src/dotty/tools/dotc/core/pickling/ClassfileConstants.scala b/src/dotty/tools/dotc/core/pickling/ClassfileConstants.scala index 5e97f373d28a..c3850d0fd76d 100644 --- a/src/dotty/tools/dotc/core/pickling/ClassfileConstants.scala +++ b/src/dotty/tools/dotc/core/pickling/ClassfileConstants.scala @@ -68,6 +68,10 @@ object ClassfileConstants { final val CONSTANT_INTFMETHODREF = 11 final val CONSTANT_NAMEANDTYPE = 12 + final val CONSTANT_METHODHANDLE = 15 + final val CONSTANT_METHODTYPE = 16 + final val CONSTANT_INVOKEDYNAMIC = 18 + // tags describing the type of a literal in attribute values final val BYTE_TAG = 'B' final val CHAR_TAG = 'C' diff --git a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala index 012fc7af36fe..c33d5c18f688 100644 --- a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala +++ b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala @@ -392,9 +392,16 @@ class ClassfileParser( case ENUM_TAG => val t = pool.getType(index) val n = pool.getName(in.nextChar) - val s = t.typeSymbol.companionModule.decls.lookup(n) - assert(s != NoSymbol, t) - if (skip) None else Some(Literal(Constant(s))) + val module = t.typeSymbol.companionModule + val s = module.info.decls.lookup(n) + if (skip) { + None + } else if (s != NoSymbol) { + Some(Literal(Constant(s))) + } else { + ctx.warning(s"""While parsing annotations in ${in.file}, could not find $n in enum $module.\nThis is likely due to an implementation restriction: an annotation argument cannot refer to a member of the annotated class (SI-7014).""") + None + } case ARRAY_TAG => val arr = new ArrayBuffer[Tree]() var hasError = false @@ -489,6 +496,13 @@ class ClassfileParser( case tpnme.ExceptionsATTR => parseExceptions(attrLen) + case tpnme.CodeATTR => + if (sym.owner is Flags.Interface) { + sym.setFlag(Flags.DefaultMethod) + ctx.log(s"$sym in ${sym.owner} is a java8+ default method.") + } + in.skip(attrLen) + case _ => } in.bp = end @@ -759,10 +773,13 @@ class ClassfileParser( (in.nextByte.toInt: @switch) match { case CONSTANT_UTF8 | CONSTANT_UNICODE => in.skip(in.nextChar) - case CONSTANT_CLASS | CONSTANT_STRING => + case CONSTANT_CLASS | CONSTANT_STRING | CONSTANT_METHODTYPE => in.skip(2) + case CONSTANT_METHODHANDLE => + in.skip(3) case CONSTANT_FIELDREF | CONSTANT_METHODREF | CONSTANT_INTFMETHODREF - | CONSTANT_NAMEANDTYPE | CONSTANT_INTEGER | CONSTANT_FLOAT => + | CONSTANT_NAMEANDTYPE | CONSTANT_INTEGER | CONSTANT_FLOAT + | CONSTANT_INVOKEDYNAMIC => in.skip(4) case CONSTANT_LONG | CONSTANT_DOUBLE => in.skip(8)