Skip to content

Javaparser #183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/dotty/tools/dotc/TypeErasure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ object TypeErasure {
def erasure(tp: Type)(implicit ctx: Context): Type = scalaErasureFn(tp)(erasureCtx)
def semiErasure(tp: Type)(implicit ctx: Context): Type = semiErasureFn(tp)(erasureCtx)
def sigName(tp: Type, isJava: Boolean)(implicit ctx: Context): TypeName = {
val seqClass = if(isJava) defn.ArrayClass else defn.SeqClass
val normTp =
if (tp.isRepeatedParam) tp.translateParameterized(defn.RepeatedParamClass, defn.SeqClass)
if (tp.isRepeatedParam) tp.translateParameterized(defn.RepeatedParamClass, seqClass)
else tp
(if (isJava) javaSigFn else scalaSigFn).sigName(normTp)(erasureCtx)
}
Expand Down
7 changes: 4 additions & 3 deletions src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -768,11 +768,12 @@ object desugar {
else // l.op(r), or val x = r; l.op(x), plus handle named args specially
makeBinop(l, op, r)
case PostfixOp(t, op) =>
if ((ctx.mode is Mode.Type) && op == nme.raw.STAR)
if ((ctx.mode is Mode.Type) && op == nme.raw.STAR) {
val seqClass = if (ctx.compilationUnit.isJava) defn.ArrayClass else defn.SeqClass
Annotated(
New(ref(defn.RepeatedAnnot.typeRef), Nil :: Nil),
AppliedTypeTree(ref(defn.SeqClass.typeRef), t))
else {
AppliedTypeTree(ref(seqClass.typeRef), t))
} else {
assert(ctx.mode.isExpr, ctx.mode)
Select(t, op)
}
Expand Down
3 changes: 3 additions & 0 deletions src/dotty/tools/dotc/core/Flags.scala
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ object Flags {
/** Symbol is a Java default method */
final val DefaultMethod = termFlag(38, "<defaultmethod>")

/** Symbol is a Java enum */
final val Enum = commonFlag(40, "<enum>")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does Enum flag in scalac have the same meaning?
if yes it would be good to add it to flag mapping that is used while reading scalac flags(see PickleBuffer class)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Done.


// Flags following this one are not pickled

/** Symbol always defines a fresh named type */
Expand Down
5 changes: 4 additions & 1 deletion src/dotty/tools/dotc/core/TypeApplications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,10 @@ class TypeApplications(val self: Type) extends AnyVal {
* or, if isJava is true, Array type, else the type itself.
*/
def underlyingIfRepeated(isJava: Boolean)(implicit ctx: Context): Type =
if (self.isRepeatedParam) translateParameterized(defn.RepeatedParamClass, defn.SeqClass)
if (self.isRepeatedParam) {
val seqClass = if(isJava) defn.ArrayClass else defn.SeqClass
translateParameterized(defn.RepeatedParamClass, seqClass)
}
else self

/** If this is an encoding of a (partially) applied type, return its arguments,
Expand Down
4 changes: 3 additions & 1 deletion src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1931,7 +1931,9 @@ object Types {
def fromSymbols(params: List[Symbol], resultType: Type)(implicit ctx: Context) = {
def paramInfo(param: Symbol): Type = param.info match {
case AnnotatedType(annot, tp) if annot matches defn.RepeatedAnnot =>
tp.translateParameterized(defn.SeqClass, defn.RepeatedParamClass)
val typeSym = param.info.typeSymbol.asClass
assert(typeSym == defn.SeqClass || typeSym == defn.ArrayClass)
tp.translateParameterized(typeSym, defn.RepeatedParamClass)
case tp =>
tp
}
Expand Down
3 changes: 2 additions & 1 deletion src/dotty/tools/dotc/core/pickling/PickleBuffer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ object PickleBuffer {
SPECIALIZED -> Specialized,
DEFAULTINIT -> DefaultInit,
VBRIDGE -> VBridge,
VARARGS -> JavaVarargs)
VARARGS -> JavaVarargs,
ENUM -> Enum)

// generate initial maps from Scala flags to Dotty flags
val termMap, typeMap = new Array[Long](64)
Expand Down
Loading