Skip to content

Fix #5916: Fix broken SemanticDB and add it to yml file for CI #5917

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

Merged
merged 3 commits into from
Feb 18, 2019
Merged
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
2 changes: 1 addition & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pipeline:
image: lampepfl/dotty:2019-02-06
commands:
- cp -R . /tmp/2/ && cd /tmp/2/
- ./project/scripts/sbt ";dotty-bootstrapped/compile ;dotty-bootstrapped/test ;sjsSandbox/run"
- ./project/scripts/sbt ";dotty-bootstrapped/compile ;dotty-bootstrapped/test; dotty-semanticdb/compile; dotty-semanticdb/test:compile;sjsSandbox/run"
- ./project/scripts/bootstrapCmdTests

community_build:
Expand Down
10 changes: 5 additions & 5 deletions compiler/src/dotty/tools/backend/jvm/AsmUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package dotty.tools
package backend
package jvm

import scala.tools.asm.tree.{AbstractInsnNode}
import scala.tools.asm.tree.{AbstractInsnNode, ClassNode, MethodNode}
import java.io.PrintWriter
import scala.tools.asm.util.{TraceClassVisitor, TraceMethodVisitor, Textifier}
import scala.tools.asm.ClassReader
Expand Down Expand Up @@ -31,7 +31,7 @@ object AsmUtils {
final val traceSerializedClassEnabled = false
final val traceSerializedClassPattern = ""

def traceMethod(mnode: MethodNode1): Unit = {
def traceMethod(mnode: MethodNode): Unit = {
println(s"Bytecode for method ${mnode.name}")
val p = new Textifier
val tracer = new TraceMethodVisitor(p)
Expand All @@ -41,7 +41,7 @@ object AsmUtils {
w.flush()
}

def traceClass(cnode: ClassNode1): Unit = {
def traceClass(cnode: ClassNode): Unit = {
println(s"Bytecode for class ${cnode.name}")
val w = new PrintWriter(System.out)
cnode.accept(new TraceClassVisitor(w))
Expand All @@ -50,8 +50,8 @@ object AsmUtils {

def traceClass(bytes: Array[Byte]): Unit = traceClass(readClass(bytes))

def readClass(bytes: Array[Byte]): ClassNode1 = {
val node = new ClassNode1()
def readClass(bytes: Array[Byte]): ClassNode = {
val node = new ClassNode()
new ClassReader(bytes).accept(node, 0)
node
}
Expand Down
24 changes: 9 additions & 15 deletions compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package backend
package jvm

import scala.tools.asm
import scala.tools.asm.ClassWriter
import scala.collection.mutable
import dotty.tools.io.AbstractFile

Expand Down Expand Up @@ -127,20 +126,6 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
}
}

/*
* can-multi-thread
*/
def createJAttribute(name: String, b: Array[Byte], offset: Int, len: Int): asm.Attribute = {
new asm.Attribute(name) {
override def write(classWriter: ClassWriter, code: Array[Byte],
codeLength: Int, maxStack: Int, maxLocals: Int): asm.ByteVector = {
val byteVector = new asm.ByteVector(len)
byteVector.putByteArray(b, offset, len)
byteVector
}
}
}

/*
* Custom attribute (JVMS 4.7.1) "ScalaSig" used as marker only
* i.e., the pickle is contained in a custom annotation, see:
Expand All @@ -166,6 +151,15 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
vp
}

/*
* can-multi-thread
*/
def createJAttribute(name: String, b: Array[Byte], offset: Int, len: Int): asm.Attribute = {
val dest = new Array[Byte](len)
System.arraycopy(b, offset, dest, 0, len)
new asm.CustomAttr(name, dest)
}

/*
* can-multi-thread
*/
Expand Down
8 changes: 4 additions & 4 deletions compiler/src/dotty/tools/backend/jvm/BCodeSkelBuilder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
final val MaximumJvmParameters = 254

// current class
var cnode: ClassNode1 = null
var cnode: asm.tree.ClassNode = null
var thisName: String = null // the internal name of the class being emitted

var claszSymbol: Symbol = null
Expand Down Expand Up @@ -88,7 +88,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
isCZStaticModule = claszSymbol.isStaticModuleClass
thisName = internalName(claszSymbol)

cnode = new ClassNode1()
cnode = new asm.tree.ClassNode()

initJClass(cnode)

Expand Down Expand Up @@ -245,7 +245,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
} // end of method addClassFields()

// current method
var mnode: MethodNode1 = null
var mnode: asm.tree.MethodNode = null
var jMethodName: String = null
var isMethSymStaticCtor = false
var returnType: BType = null
Expand Down Expand Up @@ -523,7 +523,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
mdesc,
jgensig,
mkArrayS(thrownExceptions)
).asInstanceOf[MethodNode1]
).asInstanceOf[asm.tree.MethodNode]

// TODO param names: (m.params map (p => javaName(p.sym)))

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/backend/jvm/BytecodeWriters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ trait BytecodeWriters {
private def emitAsmp(jclassBytes: Array[Byte], asmpFile: dotty.tools.io.File): Unit = {
val pw = asmpFile.printWriter()
try {
val cnode = new ClassNode1()
val cnode = new asm.tree.ClassNode()
val cr = new asm.ClassReader(jclassBytes)
cr.accept(cnode, 0)
val trace = new scala.tools.asm.util.TraceClassVisitor(new java.io.PrintWriter(new java.io.StringWriter()))
Expand Down
39 changes: 0 additions & 39 deletions compiler/src/dotty/tools/backend/jvm/ClassNode1.java

This file was deleted.

3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/backend/jvm/GenBCode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import dotty.tools.dotc.core.Phases.Phase

import scala.collection.mutable
import scala.collection.JavaConverters._
import scala.tools.asm.CustomAttr
import dotty.tools.dotc.transform.SymUtils._
import dotty.tools.dotc.interfaces
import dotty.tools.dotc.util.SourceFile
Expand Down Expand Up @@ -239,7 +240,7 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
getFileForClassfile(outF, store.name, ".hasTasty")
binary
}
val dataAttr = createJAttribute(nme.TASTYATTR.mangledString, tasty, 0, tasty.length)
val dataAttr = new CustomAttr(nme.TASTYATTR.mangledString, tasty)
store.visitAttribute(dataAttr)
}

Expand Down
31 changes: 0 additions & 31 deletions compiler/src/dotty/tools/backend/jvm/LabelNode1.java

This file was deleted.

47 changes: 0 additions & 47 deletions compiler/src/dotty/tools/backend/jvm/MethodNode1.java

This file was deleted.

2 changes: 1 addition & 1 deletion project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ object Build {

// get libraries onboard
libraryDependencies ++= Seq(
"org.scala-lang.modules" % "scala-asm" % "7.0.0-scala-1", // used by the backend
"org.scala-lang.modules" % "scala-asm" % "6.0.0-scala-1", // used by the backend
// FIXME: Not needed, but should be on the compiler CP
("org.scala-lang.modules" %% "scala-xml" % "1.1.0").withDottyCompat(scalaVersion.value),
"org.scala-lang" % "scala-library" % scalacVersion % "test",
Expand Down
2 changes: 1 addition & 1 deletion semanticdb/src/dotty/semanticdb/SemanticdbConsumer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ class SemanticdbConsumer(sourceFilePath: java.nio.file.Path) extends TastyConsum

override def traverseTree(tree: Tree)(implicit ctx: Context): Unit = {
tree match {
case Import(path, selectors) =>
case Import(_, path, selectors) =>
val key = (tree.symbol.trueName, tree.pos.start)
if (!packageDefinitions(key)) {
packageDefinitions += key
Expand Down