Playing with dictionaries and Integers on COOPER platform

The following snipped
triggers
EO EC Cannot Simplify Identifier on COOPER

import java.util
public typealias sysInt = Long!
func testrefDictionarySemantics(){
	let src = [1:"a",2:"b",3:"c"]
	let a: Dictionary<sysInt,String> = src
	
	let orig: Dictionary<sysInt,String> = a
	let ref = orig
	
	assert(a[1] == "a")
 }

When defining sysInt = Long

I get
Error (E62) Type mismatch, cannot assign “swift.Dictionary<Integer!,String!>” to “java.util.Dictionary<Long!,String>” org.me.b2 E:\offen\dshDev\silver 9 bugs\org.me.b2\org.me.b2\MainActivity.swift

in line 3

and

Error (E189) Type “java.util.Dictionary<Long!,String>!” has no default property to use for array accessors org.me.b2 E:\offen\dshDev\silver 9 bugs\org.me.b2\org.me.b2\MainActivity.swift

at the end of the function.

The following variant of the code triggers an
E0 error:
Object reference not set to an instance of an Object (no line nr. no file)
import java.util
public typealias sysInt = java.lang.Long!

func testrefDictionarySemantics(){
	let src = [1:"a",2:"b",3:"c"]
	let a: Dictionary<sysInt,String> = src
	
	let orig: Dictionary<sysInt,String> = a
	let ref = orig
	
	//assert(a[1] == "a")
	
	for (k,v) in orig{
		println("\(k):"+v)
	}
}

The following variant is particularly nasty:
It compiles but throws a java class cast exception when the loop gets entered.

//import java.util
public typealias sysInt = Int
public typealias refDictionary<Key,Value> = Dictionary<Key,Value>

extension Dictionary<sysInt,String>{

public	init(_ dict: Dictionary<sysInt,String>){
		self = dict
	}
 }

     func testrefDictionarySemantics(){
	let src = [1:"a",2:"b",3:"c"]
	let a = refDictionary<sysInt,String>(src) 
	let orig:refDictionary<sysInt,String> = a
	let ref = orig

	for (k,v) in orig{
		println("\(k):"+v)
	}
}

Having public typealias sysInt = Long yields the same as above
But having public typealias sysInt = java.lang.Integer works.

Version Info:
Microsoft Visual Studio 2015 Shell (Integrated)
Version 14.0.23107.0 D14REL
Microsoft .NET Framework
Version 4.6.00081

Installed Version: IDE Standard

RemObjects Elements 9.0.97.2071
RemObjects Elements (Oxygene, C# and Silver) for .NET, Cocoa and Java.
Copyright 2003-2016 RemObjects Software, LLC. All rights reserved.
http://www.remobjects.com/elements

RemObjects Elements leverages the LLVM compiler backend:
Copyright © 2003-2016 University of Illinois at Urbana-Champaign. All rights reserved.
http://llvm.org

RemObjects Everwood 4.7.79.695
RemObjects Everwood
Copyright RemObjects Software, LLC 2002-2016. All Rights Reserved.
http://www.remobjects.com/everwood

Thanks, logged as bugs://77302

bugs://77302 got closed with status fixed.

So I fixed the first two. The last one isn’t really a bug.

The type of [1: “test”, 2: “test”]
is Swift.Dictionary<Integer, String>, casting that to a dictionary Long (Swift Int is 64bits too) won’t work. it will unbox the wrong types.

Well all those bugs got me confused, about what is supposed to work and what isn’t, i guess ;).

1 Like

Fair enough

bugs://i65033 was closed as fixed.

Logged as bugs://i65033.