Strum355
04/30/2018, 11:03 PMStrum355
04/30/2018, 11:03 PMval cpuDataType = object : TypeToken<HashMap<String, CPUData>>() {}.type
cpuMap = parser.fromJson(InputStreamReader(input), cpuDataType)
input = assetManager.open("GPU_MAP.json")
val gpuDataType = object : TypeToken<HashMap<String, GPUData>>() {}.type
gpuMap = parser.fromJson(InputStreamReader(input), gpuDataType)
Strum355
04/30/2018, 11:03 PMStrum355
04/30/2018, 11:04 PMStrum355
04/30/2018, 11:04 PMStrum355
04/30/2018, 11:05 PMShawn
04/30/2018, 11:05 PMKClass<T>
Strum355
04/30/2018, 11:07 PMprivate fun getData(file: String, type: KClass<Hardware>)
Shawn
04/30/2018, 11:08 PMStrum355
04/30/2018, 11:08 PMimage.png▾
Shawn
04/30/2018, 11:09 PMCPUData
doesn’t inherit from or implement Hardware
that seems about rightStrum355
04/30/2018, 11:09 PMStrum355
04/30/2018, 11:09 PMimage.png▾
Shawn
04/30/2018, 11:11 PMKClass<out Hardware>
though I’m not sure that ends up helping you do whatever you’re doingStrum355
04/30/2018, 11:11 PMShawn
04/30/2018, 11:11 PMStrum355
04/30/2018, 11:11 PMShawn
04/30/2018, 11:11 PMStrum355
04/30/2018, 11:11 PMShawn
04/30/2018, 11:13 PMStrum355
04/30/2018, 11:14 PMAJ Alt
04/30/2018, 11:17 PM// works, returns 1
fun foo(): Int {
while (true) return 1
}
//Type mismatch: inferred type is Unit but Int was expected
fun bar(): () -> Int = l@{
while (true) return@l 1
}
// works, returns 1, but results in 'Warning: Unreachable code'
fun baz(): () -> Int = l@{
while (true) return@l 1
2
}
I understand what's happening, but is there a documented reason that bar
wouldn't compile, or should I file an issue?Shawn
04/30/2018, 11:20 PMwhile
AJ Alt
04/30/2018, 11:20 PMShawn
04/30/2018, 11:21 PMShawn
04/30/2018, 11:21 PMShawn
04/30/2018, 11:22 PMUnit
it isShawn
04/30/2018, 11:22 PMShawn
04/30/2018, 11:25 PMInt
rtype, but I imagine this is a corner case that they weren’t anticipating when building Kotlin’s type systemShawn
04/30/2018, 11:27 PM