Skip to content

Instantly share code, notes, and snippets.

@enshahar
Created August 12, 2017 10:31
Show Gist options
  • Save enshahar/35cc23134d1381f3b5e3a20ace2ec141 to your computer and use it in GitHub Desktop.
Save enshahar/35cc23134d1381f3b5e3a20ace2ec141 to your computer and use it in GitHub Desktop.
kotlin compile error?

At first the compiler can compile the SubPackage.kt correctly. But if I run the compiler again, it cannot process the imported references.

D:\work\kotlin\tmp λ kotlinc Package.kt
Picked up JAVA_TOOL_OPTIONS: -Xmx8g

D:\work\kotlin\tmp λ kotlinc SubPackage.kt -cp .
Picked up JAVA_TOOL_OPTIONS: -Xmx8g

D:\work\kotlin\tmp λ kotlinc SubPackage.kt -cp .
Picked up JAVA_TOOL_OPTIONS: -Xmx8g
SubPackage.kt:4:20: error: unresolved reference: circleArea
import com.jnfsoft.circleArea
                   ^
SubPackage.kt:5:20: error: unresolved reference: Pi
import com.jnfsoft.Pi
                   ^
SubPackage.kt:13:66: error: unresolved reference: Pi
fun sphereVolume(r:Double) = 4.0 / 3.0 * r * r * r * com.jnfsoft.Pi
                                                                 ^
SubPackage.kt:15:36: error: unresolved reference: Pi
fun circleArea(r:Double) = r * r * Pi
                                   ^
// Package.kt
package com.jnfsoft
class A(val radius:Double) {
val name = "com.jnfsoft.A"
fun area() = com.jnfsoft.circleArea(radius)
}
val Pi = 3.141592
fun circleArea(r:Double) = r * r * Pi
// SubPackage.kt
package com.jnfsoft.sub
import com.jnfsoft.circleArea
import com.jnfsoft.Pi
class A() {
val name = "com.jnfsoft.sub.A"
fun area(radius:Double) = circleArea(radius)
}
fun sphereVolume(r:Double) = 4.0 / 3.0 * r * r * r * com.jnfsoft.Pi
fun circleArea(r:Double) = r * r * Pi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment