diff options
author | Guillaume Martres <smarter@ubuntu.com> | 2016-06-02 18:49:05 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-07-27 19:28:36 +0200 |
commit | 1fa136f3be21dce9eae2d09d7cee959ede48e177 (patch) | |
tree | b8587e10bf725bff3ba6dbf6b363388864709bc1 /src | |
parent | 50c80e83d301720795a40a2b3347dad45774e4e7 (diff) | |
download | dotty-1fa136f3be21dce9eae2d09d7cee959ede48e177.tar.gz dotty-1fa136f3be21dce9eae2d09d7cee959ede48e177.tar.bz2 dotty-1fa136f3be21dce9eae2d09d7cee959ede48e177.zip |
Remove overloaded constructor for annotations
This lead to inference failures when separately compiling t1751 and
t294, this did not happen under joint compilation because JavaParser
does not create the overloaded constructor
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/core/classfile/ClassfileParser.scala | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala b/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala index 813376655..a6d381693 100644 --- a/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala +++ b/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala @@ -580,9 +580,6 @@ class ClassfileParser( * parameters. For Java annotations we need to fake it by making up the constructor. * Note that default getters have type Nothing. That's OK because we need * them only to signal that the corresponding parameter is optional. - * If the constructor takes as last parameter an array, it can also accept - * a vararg argument. We solve this by creating two constructors, one with - * an array, the other with a repeated parameter. */ def addAnnotationConstructor(classInfo: Type, tparams: List[TypeSymbol] = Nil)(implicit ctx: Context): Unit = { def addDefaultGetter(attr: Symbol, n: Int) = @@ -618,13 +615,26 @@ class ClassfileParser( } addConstr(paramTypes) + + // The code below added an extra constructor to annotations where the + // last parameter of the constructor is an Array[X] for some X, the + // array was replaced by a vararg argument. Unfortunately this breaks + // inference when doing: + // @Annot(Array()) + // The constructor is overloaded so the expected type of `Array()` is + // WildcardType, and the type parameter of the Array apply method gets + // instantiated to `Nothing` instead of `X`. + // I'm leaving this commented out in case we improve inference to make this work. + // Note that if this is reenabled then JavaParser will also need to be modified + // to add the extra constructor (this was not implemented before). + /* if (paramTypes.nonEmpty) paramTypes.last match { case defn.ArrayOf(elemtp) => addConstr(paramTypes.init :+ defn.RepeatedParamType.appliedTo(elemtp)) case _ => } - + */ } } |