# Playing with dictionaries and Integers on COOPER platform

**URL:** https://talk.remobjects.com/t/playing-with-dictionaries-and-integers-on-cooper-platform/12306
**Category:** Silver
**Created:** [February 23, 2017, 7:40pm UTC](https://talk.remobjects.com/t/playing-with-dictionaries-and-integers-on-cooper-platform/12306 "2017-02-23T19:40:04Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Kay\_Grossblotekamp](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/k/7feea3/32.png) [@Kay\_Grossblotekamp](https://talk.remobjects.com/u/Kay_Grossblotekamp)
#### Post date: [February 23, 2017, 7:40pm UTC](https://talk.remobjects.com/t/playing-with-dictionaries-and-integers-on-cooper-platform/12306/1 "2017-02-23T19:40:05Z")

</div>

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](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](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](http://www.remobjects.com/everwood)

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [February 24, 2017, 6:47am UTC](https://talk.remobjects.com/t/playing-with-dictionaries-and-integers-on-cooper-platform/12306/2 "2017-02-24T06:47:48Z")

</div>

Thanks, logged as bugs://77302

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [February 27, 2017, 1:21pm UTC](https://talk.remobjects.com/t/playing-with-dictionaries-and-integers-on-cooper-platform/12306/3 "2017-02-27T13:21:31Z")

</div>

bugs://77302 got closed with status fixed.

---

<div class="post-metadata">

### Author: ![ck](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ck/32/8740_2.png) [@ck](https://talk.remobjects.com/u/ck)
#### Post date: [February 27, 2017, 1:23pm UTC](https://talk.remobjects.com/t/playing-with-dictionaries-and-integers-on-cooper-platform/12306/4 "2017-02-27T13:23:52Z")

</div>

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

> [@Kay\_Grossblotekamp](#):
>
> Having public typealias sysInt = Long yields the same as aboveBut having public typealias sysInt = java.lang.Integer works.

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.

---

<div class="post-metadata">

### Author: ![Kay\_Grossblotekamp](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/k/7feea3/32.png) [@Kay\_Grossblotekamp](https://talk.remobjects.com/u/Kay_Grossblotekamp)
#### Post date: [March 1, 2017, 10:07am UTC](https://talk.remobjects.com/t/playing-with-dictionaries-and-integers-on-cooper-platform/12306/5 "2017-03-01T10:07:20Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ck](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ck/32/8740_2.png) [@ck](https://talk.remobjects.com/u/ck)
#### Post date: [March 1, 2017, 10:10am UTC](https://talk.remobjects.com/t/playing-with-dictionaries-and-integers-on-cooper-platform/12306/6 "2017-03-01T10:10:02Z")

</div>

Fair enough

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [September 1, 2020, 5:56am UTC](https://talk.remobjects.com/t/playing-with-dictionaries-and-integers-on-cooper-platform/12306/7 "2020-09-01T05:56:47Z")

</div>

[bugs://i65033](https://www.remobjects.com/portal/bugs/?id=i65033) was closed as fixed.

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [September 1, 2020, 5:56am UTC](https://talk.remobjects.com/t/playing-with-dictionaries-and-integers-on-cooper-platform/12306/8 "2020-09-01T05:56:48Z")

</div>

Logged as [bugs://i65033](https://www.remobjects.com/portal/bugs/?id=i65033).
