Skip to content

Commit 0b52037

Browse files
Merge pull request #6941 from dotty-staging/architectural-improvements
Minor architectural clean-up
2 parents 939a07e + b7a433c commit 0b52037

File tree

4 files changed

+9
-21
lines changed

4 files changed

+9
-21
lines changed

compiler/src/dotty/tools/backend/sjs/JUnitBootstrappers.scala

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,7 @@ class JUnitBootstrappers extends MiniPhase {
229229
val testAnnot = test.getAnnotation(junitdefn.TestAnnotClass).get
230230
if (testAnnot.arguments.nonEmpty)
231231
ctx.error("@Test annotations with arguments are not yet supported in Scala.js for dotty", testAnnot.tree.sourcePos)
232-
val noArgConstr = junitdefn.TestAnnotType.member(nme.CONSTRUCTOR).suchThat(_.info.paramInfoss.head.isEmpty).symbol.asTerm
233-
val reifiedAnnot = New(junitdefn.TestAnnotType, noArgConstr, Nil)
232+
val reifiedAnnot = resolveConstructor(junitdefn.TestAnnotType, Nil)
234233
New(junitdefn.TestMetadataType, List(name, ignored, reifiedAnnot))
235234
}
236235
JavaSeqLiteral(metadata, TypeTree(junitdefn.TestMetadataType))
@@ -250,11 +249,7 @@ class JUnitBootstrappers extends MiniPhase {
250249
ValDef(castInstanceSym, instanceParamRef.cast(testClass.typeRef)) :: Nil,
251250
tests.foldRight[Tree] {
252251
val tp = junitdefn.NoSuchMethodExceptionType
253-
val constr = tp.member(nme.CONSTRUCTOR).suchThat { c =>
254-
c.info.paramInfoss.head.size == 1 &&
255-
c.info.paramInfoss.head.head.isRef(defn.StringClass)
256-
}.symbol.asTerm
257-
Throw(New(tp, constr, nameParamRef :: Nil))
252+
Throw(resolveConstructor(tp, nameParamRef :: Nil))
258253
} { (test, next) =>
259254
If(Literal(Constant(test.name.toString)).select(defn.Any_equals).appliedTo(nameParamRef),
260255
genTestInvocation(testClass, test, ref(castInstanceSym)),

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,5 +1362,10 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
13621362
}
13631363
transformer.transform(tree)
13641364
}
1365+
1366+
def resolveConstructor(atp: Type, args:List[Tree])(implicit ctx: Context): Tree = {
1367+
val targs = atp.argTypes
1368+
tpd.applyOverloaded(New(atp.typeConstructor), nme.CONSTRUCTOR, args, targs, atp)
1369+
}
13651370
}
13661371

compiler/src/dotty/tools/dotc/core/Annotations.scala

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,6 @@ object Annotations {
115115
def apply(atp: Type, args: List[Tree])(implicit ctx: Context): Annotation =
116116
apply(New(atp, args))
117117

118-
private def resolveConstructor(atp: Type, args:List[Tree])(implicit ctx: Context): Tree = {
119-
val targs = atp.argTypes
120-
tpd.applyOverloaded(New(atp.typeConstructor), nme.CONSTRUCTOR, args, targs, atp)
121-
}
122-
123-
def applyResolve(atp: Type, args: List[Tree])(implicit ctx: Context): Annotation = {
124-
apply(resolveConstructor(atp, args))
125-
}
126-
127118
/** Create an annotation where the tree is computed lazily. */
128119
def deferred(sym: Symbol)(treeFn: given Context => Tree)(implicit ctx: Context): Annotation =
129120
new LazyAnnotation {

compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -934,11 +934,8 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
934934
}
935935
t.toList
936936
}
937-
// println(atp)
938-
val targs = atp.argTypes
939-
940-
tpd.applyOverloaded(tpd.New(atp.typeConstructor), nme.CONSTRUCTOR, args, targs, atp)
941-
}
937+
resolveConstructor(atp, args)
938+
}
942939

943940
/** Read an annotation and as a side effect store it into
944941
* the symbol it requests. Called at top-level, for all

0 commit comments

Comments
 (0)